package com.sportizz.sport.row;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import java.util.Timer;
import java.util.TimerTask;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.CalendarContract;
import android.provider.CalendarContract.Events;
import android.provider.CalendarContract.Instances;
import android.provider.CalendarContract.Reminders;
import android.text.InputType;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.Toast;

import com.facebook.Session;
import com.facebook.widget.WebDialog;
import com.sportizz.model.ImageLoader;
import com.sportizz.model.Player;
import com.sportizz.sport.AlertDialogManager;
import com.sportizz.sport.DatabaseAdapter;
import com.sportizz.sport.DbHandler;
import com.sportizz.sport.Fb_dialog_box;
import com.sportizz.sport.MainActivity;
import com.sportizz.sport.R;
import com.sportizz.sport.StartActivity;
import com.sportizz.sport.Utils;
import com.sportizz.sport.custom_follow_dialog;

public class PlayerRow implements Row {

	private final Player player;
	private final LayoutInflater inflater;
	protected Activity act_context;
	private boolean press1 = false;
	private boolean press2 = false;
	String device_id = null;
	String country_code = null;
	String Player_id1 = null;
	ImageLoader imgLoader;
	private DatabaseAdapter mDbHelper;
	DbHandler handler;
	StartActivity sa = new StartActivity();
	
	Context con;
	
	String p_channel1 = null;
	String p_channel2 = null;
	String p_channel3 = null;
	AlertDialogManager alert = new AlertDialogManager();

	public ProgressDialog pd;

	AlertDialog.Builder alertDialog = null;
	Typeface font_player;

	public PlayerRow(LayoutInflater inflater, Player player, Context context) {

		this.con = context;
		this.player = player;
		this.inflater = inflater;
		this.act_context = (Activity) context;
		imgLoader = new ImageLoader(con.getApplicationContext());
	}

	@SuppressLint({ "NewApi", "SimpleDateFormat" })
	@Override
	public View getView(View convertView) {
		device_id = sa.GetDeviceID(act_context);
		country_code = StartActivity.GetCountryCode(act_context);
		handler = new DbHandler(act_context);
		final ViewHolder holder;

		View view;
		if (convertView == null) {

			ViewGroup viewgroup = (ViewGroup) inflater.inflate(
					R.layout.new_custom_row_player, null);

			holder = new ViewHolder(
					(LinearLayout)viewgroup.findViewById(R.id.head_rel),
					(TextView) viewgroup.findViewById(R.id.new_txt_pday),
					(TextView) viewgroup.findViewById(R.id.new_txt_pdate),
					(TextView) viewgroup.findViewById(R.id.new_sport_p_name),
					(TextView) viewgroup.findViewById(R.id.new_champ_txt),
					(TextView) viewgroup.findViewById(R.id.txt_pgame),
					(TextView) viewgroup.findViewById(R.id.txt_pmatch),
					(ImageView) viewgroup.findViewById(R.id.new_image_p1),
					(ImageView) viewgroup.findViewById(R.id.new_image_p2),

					(TextView) viewgroup.findViewById(R.id.new_txt_player1),
					(TextView) viewgroup.findViewById(R.id.new_txt_player2),

					(TextView) viewgroup.findViewById(R.id.new_txt_player3),
					(TextView) viewgroup.findViewById(R.id.new_txt_player4),

					(TableRow) viewgroup.findViewById(R.id.tableRow3),

					(TextView) viewgroup.findViewById(R.id.new_img_p_channel2),
					(TextView) viewgroup.findViewById(R.id.new_img_p_channel1),
					(TextView) viewgroup.findViewById(R.id.new_img_p_channel3),

					(Button) viewgroup.findViewById(R.id.new_btn_p_follow1),
					(Button) viewgroup.findViewById(R.id.new_btn_p_follow2),
					(Button) viewgroup.findViewById(R.id.new_btn_player_addcal),
					(Button) viewgroup.findViewById(R.id.ticket_player)); // (TextView)
																			// viewgroup.findViewById(R.id.game_txt),
																			// ,
																			// (Button)
																			// viewgroup.findViewById(R.id.btn_fbshare_pl)

			viewgroup.setTag(holder);

			view = viewgroup;
		} else {
			holder = (ViewHolder) convertView.getTag();

			view = convertView;
		}

		Typeface sport_font = Typeface.createFromAsset(act_context.getAssets(),
				"hel57.ttf");
		
		holder.follow1.setTypeface(sport_font);
		holder.follow2.setTypeface(sport_font);
		holder.btn_player_cal.setTypeface(sport_font);

		holder.player1.setTypeface(sport_font);
		holder.player2.setTypeface(sport_font);
		holder.player3.setTypeface(sport_font);
		holder.player4.setTypeface(sport_font);

		holder.follow1.setTag(player.getplayer_code1().toString());
		holder.follow2.setTag(player.getplayer_code2().toString());

		if (player.geti_foll() == true) {
			holder.follow1.setVisibility(View.GONE);
			holder.follow2.setVisibility(View.GONE);
		}

		holder.btn_player_cal.setTypeface(sport_font);
		
		
		holder.follow1.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Log.v("suraj", "Device Id pr=" + device_id);

				mDbHelper = new DatabaseAdapter(act_context);
				mDbHelper.open();

				StartActivity.foll_count = StartActivity.follow_count.getInt(
						"follow_count", 0);

				Log.e("suraj", "StartActivity.foll_count = "
						+ StartActivity.foll_count);

//				if (StartActivity.foll_count < StartActivity.limited_follow
//						.getInt("max_follow", 3)
//						&& StartActivity.foll_count >= 0) {
					String btn_name = holder.follow1.getText().toString();

					if (player.getgametext().contains("Double") == true) {
						Log.w("suraj", "Show Dialog");
						final custom_follow_dialog dialog = new custom_follow_dialog(
								act_context, device_id, player
										.getplayer_code1(),
								player.getplayer1(), player
										.getplayer1_country(), player
										.getplayer_code3(),
								player.getplayer3(), player
										.getplayer3_country(), player
										.getsport_code(), player.getsport(),
								player.getteam());

						dialog.show();

						final Timer t = new Timer();
						t.schedule(new TimerTask() {
							public void run() {
								dialog.dismiss();
								t.cancel();
								// return ;
							}
						}, 15000);

					} else {

						if (btn_name.equals("FOLLOW")) {

							Log.d("suraj",
									"player_code = " + player.getplayer_code1());

							AsyncTask<Void, Void, Void> wait = new AsyncTask<Void, Void, Void>() {

								@Override
								protected void onPostExecute(Void result) {
									super.onPostExecute(result);
									pd.dismiss();
									mDbHelper.close();
								}

								@Override
								protected void onPreExecute() {

									pd = ProgressDialog.show(act_context, "",
											"Following...", true);
									super.onPreExecute();
								}

								@Override
								protected Void doInBackground(Void... params) {

									long c = mDbHelper.insert_follow_info(
											player.getplayer_code1(),
											player.getplayer1(),
											player.getsport_code(),
											player.getsport(),
											player.getplayer1_country(),
											player.getteam(),"P");
									
									String response = Utils
											.getJSONString("http://sportizza.com/interface/ios_follow.php?dev_id="
													+ device_id
													+ "&iso_cd="
													+ country_code
													+ "&follow="
													+ player.getplayer_code1()
													+ "&follow_cs=-1");

									if (c != 0) {
										Thread t = new Thread(new Runnable() {
											public void run() {

												act_context
														.runOnUiThread(new Runnable() {
															public void run() {
																Toast.makeText(
																		act_context
																				.getApplicationContext(),
																		"Added to I follow",
																		Toast.LENGTH_SHORT)
																		.show();
																Log.d("suraj",
																		"follow success..");
																holder.follow1
																		.setText("UNFOLLOW");
																MainActivity.playerAll
																		.add(player
																				.getplayer_code1());

																StartActivity.foll_count++;

																SharedPreferences.Editor editor = StartActivity.follow_count
																		.edit();
																editor.putInt(
																		"follow_count",
																		StartActivity.foll_count);
																editor.commit();
															}
														});
											}
										});
										t.start();

									} else {
										Toast.makeText(
												act_context
														.getApplicationContext(),
												"Error during follow",
												Toast.LENGTH_SHORT).show();
									}

									press1 = true;
//									mDbHelper.close();

									return null;
								}
							};
							wait.execute();
						} 
					}
//						else if (press1 == true) {
//							Log.d("suraj", "Already follow");
//						}
//					}
//			else {
//
//					Toast.makeText(act_context.getApplicationContext(),
//							"Reach to Maximum Follow count....",
//							Toast.LENGTH_LONG).show();
//					Pay_dialog_box pdb = new Pay_dialog_box(act_context);
//					pdb.show();
//				}

			}

		});

		holder.follow2.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				mDbHelper = new DatabaseAdapter(act_context);
				mDbHelper.open();

				StartActivity.foll_count = StartActivity.follow_count.getInt(
						"follow_count", 0);

				Log.e("suraj", "StartActivity.foll_count = "
						+ StartActivity.foll_count);

//				if (StartActivity.foll_count < StartActivity.limited_follow
//						.getInt("max_follow", 3)
//						&& StartActivity.foll_count >= 0) {
					String btn_name2 = holder.follow2.getText().toString();

					if (player.getgametext().contains("Double") == true) {
						Log.w("suraj", "Show Dialog");
						final custom_follow_dialog dialog = new custom_follow_dialog(
								act_context, device_id, player
										.getplayer_code2(),
								player.getplayer2(), player
										.getplayer2_country(), player
										.getplayer_code4(),
								player.getplayer4(), player
										.getplayer4_country(), player
										.getsport_code(), player.getsport(),
								player.getteam());

						dialog.show();

						final Timer t = new Timer();
						t.schedule(new TimerTask() {
							public void run() {
								dialog.dismiss();
								t.cancel();
								// return ;
							}
						}, 10000);

					} else {

						if (btn_name2.equals("FOLLOW")) {

							AsyncTask<Void, Void, Void> wait = new AsyncTask<Void, Void, Void>() {

								@Override
								protected void onPostExecute(Void result) {
									super.onPostExecute(result);
									pd.dismiss();
									mDbHelper.close();
								}

								@Override
								protected void onPreExecute() {

									pd = ProgressDialog.show(act_context, "",
											"Following...", true);
									super.onPreExecute();
								}

								@Override
								protected Void doInBackground(Void... params) {
									try {

										Log.d("suraj", "player_code = "
												+ player.getplayer_code2());

										long c = mDbHelper.insert_follow_info(
												player.getplayer_code2(),
												player.getplayer2(),
												player.getsport_code(),
												player.getsport(),
												player.getplayer2_country(),
												player.getteam(),"P");

										String response1 = Utils.getJSONString("http://sportizza.com/interface/ios_follow.php?dev_id="
												+ device_id
												+ "&iso_cd="
												+ country_code
												+ "&follow="
												+ player.getplayer_code2()
												+ "&follow_cs=-1");

										if (c != 0) {
											Thread t = new Thread(
													new Runnable() {
														public void run() {

															act_context
																	.runOnUiThread(new Runnable() {
																		public void run() {
																			Toast.makeText(
																					act_context
																							.getApplicationContext(),
																					"Added to I follow",
																					Toast.LENGTH_SHORT)
																					.show();
																			Log.d("suraj",
																					"follow success..");
																			holder.follow2
																					.setText("UNFOLLOW");

																			MainActivity.playerAll
																					.add(player
																							.getplayer_code2());

																			StartActivity.foll_count++;

																			SharedPreferences.Editor editor = StartActivity.follow_count
																					.edit();
																			editor.putInt(
																					"follow_count",
																					StartActivity.foll_count);
																			editor.commit();
																		}
																	});
														}
													});
											t.start();
										} else {
											Toast.makeText(
													act_context
															.getApplicationContext(),
													"Error during follow",
													Toast.LENGTH_SHORT).show();
										}

										press2 = true;

									} catch (Exception e) {
										Toast.makeText(
												act_context
														.getApplicationContext(),
												"Connection Problem Please Check Connectivity",
												Toast.LENGTH_SHORT).show();
									}

									return null;
								}
							};
							wait.execute();

						} 
//						else if (press2 == true) {
//							Log.d("suraj", "Already follow");
//						}
//					}
				} 
//			else {
//
//					Toast.makeText(act_context.getApplicationContext(),
//							"Reach to Maximum Follow count....",
//							Toast.LENGTH_LONG).show();
//
//					Pay_dialog_box pdb = new Pay_dialog_box(act_context);
//					pdb.show();
//
//					// act_context.startActivity(new
//					// Intent(act_context,Sample_Act.class));
//
//				}
//				mDbHelper.close();

			}
		});

		holder.btn_player_cal.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// if (MainActivity.check_cal.isChecked() == true) {
				String date_str = player.getDate1();

				Log.v("suraj", "DAte = " + date_str);

				Long start_date_mili = null;

				String title = null;

				if (player.getgametext().contains("Double") == true) {
					title = player.getplayer1() + " / " + player.getplayer3()
							+ " Vs " + player.getplayer2() + " / "
							+ player.getplayer4() + " - "
							+ player.getChamp_name();
				} else {
					title = player.getplayer1() + " Vs " + player.getplayer2()
							+ " - " + player.getChamp_name();
				}

				String Desc = "SPORTIZZA";

				SimpleDateFormat dateFormat11 = new SimpleDateFormat(
						"dd-MM-yyyy hh:mm a");

				Date date11 = null;

				try {
					date11 = dateFormat11.parse(date_str);
				} catch (ParseException e) {
					e.printStackTrace();
				}

				start_date_mili = date11.getTime();

				try {

					long begin = start_date_mili;
					long end = start_date_mili + 30 * 60 * 1000;// ending
																// time
																// in
																// milliseconds
					String[] proj = new String[] { Instances._ID,
							Instances.BEGIN, Instances.END, Instances.EVENT_ID };

					Cursor cursor = Instances.query(
							act_context.getContentResolver(), proj, begin, end);

					cursor.moveToFirst();

					if (cursor.getCount() > 0) {

						String title_cal = cursor.getString(cursor
								.getColumnIndex("title"));

						if (title_cal.equals(title)) {
							Log.i("suraj",
									"Cursor = "
											+ cursor.getString(cursor
													.getColumnIndex("title")));

							Toast.makeText(act_context,
									"Already Added to Calendar..",
									Toast.LENGTH_SHORT).show();
						} else {
							Log.i("suraj", "Add to calendar = " + title);

							addToCalendar(act_context, title, Desc,
									start_date_mili,
									start_date_mili + 30 * 60 * 1000);
							Toast.makeText(act_context, "Added to Calender..",
									Toast.LENGTH_SHORT).show();

						}
					} else {
						Log.i("suraj", "Add to calendar = " + title);
						addToCalendar(act_context, title, Desc,
								start_date_mili,
								start_date_mili + 30 * 60 * 1000);
						Toast.makeText(act_context, "Added to Calender..",
								Toast.LENGTH_SHORT).show();

					}
				} catch (Exception e) {
					e.printStackTrace();
				}
				// } else {
				// Toast.makeText(act_context,
				// "Access Calendar is off in setting",
				// Toast.LENGTH_SHORT).show();
				// }
			}
		});

		String player_country1 = null, player_country2 = null;
		if (player.gettablet() == false) {
			if (player.getgametext().contains("Double") == true) {
				
				Bitmap bi_result = null ;
				
				try {
					 bi_result = BitmapFactory.decodeStream(act_context
							.getResources()
							.getAssets()
							.open("sport_small/"+ player.getsport_code() + "_S.png"));
				} catch (IOException e1) {
					e1.printStackTrace();
					try {
						 bi_result = BitmapFactory.decodeStream(act_context
								.getResources()
								.getAssets()
								.open("sport_small/GAM_S.png"));
					} catch (IOException e2) {
						
					}
				}
				
				holder.image_p1.setImageBitmap(bi_result);
				holder.image_p2.setImageBitmap(bi_result);
				
			}
			else
			{
			player_country1 = "" + StartActivity.get_img_location
					+ "phone/country/" + player.getplayer1_country()
					+ ".png";
			
			
//			new imageTask(holder.image_p1).execute(player_country1);

			int loader = getImgLoader(player.getsport_code());
			
			imgLoader.DisplayImage(player_country1,loader,holder.image_p1);
			
			player_country2 = "" + StartActivity.get_img_location
					+ "phone/country/" + player.getplayer2_country()
					+ ".png";
			
//			new imageTask(holder.image_p2).execute(player_country2);
			
//			int loader = getImgLoader(player.getsport_code());
			
			imgLoader.DisplayImage(player_country2,loader,holder.image_p2);
			}
		} else {
			player_country1 = "" + StartActivity.get_img_location
					+ "pad/country/" + player.getplayer1_country()
					+ "@2x.png";
			
//			new imageTask(holder.image_p1).execute(player_country1);

			int loader = getImgLoader(player.getsport_code());
			
			imgLoader.DisplayImage(player_country1,loader,holder.image_p1);
			
			player_country2 = "" + StartActivity.get_img_location
					+ "pad/country/" + player.getplayer2_country()
					+ "@2x.png";
			
//			int loader = getImgLoader(player.getsport_code());
			
			imgLoader.DisplayImage(player_country2,loader,holder.image_p2);
			
//			new imageTask(holder.image_p2).execute(player_country2);
		}

		String[] date_= player.getDate().split(" ");
		holder.date.setText(date_[0]+"\n"+date_[1]+" "+date_[2]);
		holder.date.setTypeface(sport_font);
		// holder.date.setTextColor(Color.WHITE);
//		holder.date.setTextSize(13);
//		holder.date.setGravity(Gravity.LEFT);

		holder.day.setText(" "+player.getDay());
		holder.day.setTypeface(sport_font);
		
		// holder.day.setTextColor(Color.WHITE);
//		holder.day.setTextSize(13);
//		holder.day.setGravity(Gravity.RIGHT);

//		if (player.getgametext().equals("null") || player.getgametext() == null) {
//
//		} else {
//			holder.game_txt.setText(player.getgametext());
//			holder.game_txt.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 9);
//			holder.game_txt.setTextColor(Color.WHITE);
//			holder.game_txt
//					.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
//		}

		if(player.getup_y_team()==true)
		{
			holder.linearLayout.setVisibility(View.GONE);
		}
		

		holder.sport_name.setText(player.getsport());
		holder.sport_name.setTypeface(sport_font);
//		holder.sport_name.setGravity(Gravity.LEFT);
		holder.sport_name.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
//		holder.sport_name.setTextSize(10);
//		holder.sport_name.setTextColor(Color.WHITE);

		holder.champ_name.setText(" "+player.getChamp_name());
//		holder.champ_name.setGravity(Gravity.CENTER);
//		String sp_cd=StartActivity.newsport_name.get(player.getsport().toString());
//		
//		String[] sp=sp_cd.split(":");
		
		if(player.getgametext()==null || player.getgametext().equals("")||player.getgametext().contains("null"))
		{
			holder.game_txt.setText("");
		}else
		{
			holder.game_txt.setText(player.getgametext());
			holder.game_txt.setTypeface(sport_font);
		}
		
		if(player.getmatchtext()==null || player.getmatchtext().equals("")||player.getmatchtext().contains("null"))
		{
			holder.match_txt.setText("");
		}else
		{
			holder.match_txt.setText(player.getmatchtext());
			holder.match_txt.setTypeface(sport_font);
		}
		
		if(player.getticket().equals("hide"))
		{
			 holder.ticket.setVisibility(View.INVISIBLE);
		}
		
		holder.ticket.setTypeface(sport_font);
		
		holder.ticket.setOnClickListener(new OnClickListener() {
	
			@Override
			public void onClick(View arg0) {
		
				if(player.getticket().equals("") || player.getticket()==null)
				{
					Toast.makeText(act_context, "Check back later..", Toast.LENGTH_SHORT).show();
				}
				else
				{
					
					Fb_dialog_box pdb = new Fb_dialog_box(act_context,player.getticket());
					pdb.show();
					
				}
				
			}
		});
		
		Bitmap bi_result = null ;
		
		try {
			 bi_result = BitmapFactory.decodeStream(act_context
					.getResources()
					.getAssets()
					.open("sport_small/"+ player.getsport_code() + "_S.png"));
		} catch (IOException e1) {
			e1.printStackTrace();
			try {
				 bi_result = BitmapFactory.decodeStream(act_context
						.getResources()
						.getAssets()
						.open("sport_small/GAM_S.png"));
			} catch (IOException e2) {
				
			}
		}
		
		if(bi_result==null)
		{
			holder.champ_name.setCompoundDrawablesWithIntrinsicBounds( R.drawable.team_selected, 0, 0, 0);
			
			holder.champ_name.setTypeface(sport_font);
			holder.champ_name.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
		}
		else
		{
		Bitmap	bitmap = Bitmap.createScaledBitmap(bi_result,20, 20, true);
		
		Drawable tmpDraw = (Drawable) new BitmapDrawable(act_context.getResources(),bitmap);
		
		holder.champ_name.setCompoundDrawablesWithIntrinsicBounds( tmpDraw, null, null, null);
		
		
		holder.champ_name.setTypeface(sport_font);
		holder.champ_name.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
		}
		
		if (player.getgametext().contains("Double") == true) {
			holder.tab_row3.setVisibility(View.VISIBLE);
			if (player.getplayer1().equalsIgnoreCase("NONE")
					&& player.getplayer3().equalsIgnoreCase("NONE")) {
			} else if (player.getplayer1() != "NONE"
					&& player.getplayer3() != "NONE") {

				holder.player1.setSelected(true);
				holder.player3.setSelected(true);
				
				holder.player1.setText(player.getplayer1());
				holder.player3.setText(player.getplayer3());

				holder.player1
						.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
				holder.player3
						.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

//				holder.player1.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
//				holder.player3.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
			}

			if (player.getplayer2().equalsIgnoreCase("NONE")
					|| player.getplayer4().equalsIgnoreCase("NONE")) {
			} else {
				holder.player2.setSelected(true);
				holder.player4.setSelected(true);
				
				holder.player2.setText(player.getplayer2());
				holder.player4.setText(player.getplayer4());

				holder.player2
						.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
				holder.player4
						.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

//				holder.player2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
//				holder.player4.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
			}

			InputStream is1 = null;
			try {
				if (player.gettablet() == false) {
					is1 = act_context
							.getResources()
							.getAssets()
							.open("new_sports/"
									+ player.getsport_code() + ".png");
					
					if(is1==null)
					{
						is1 = act_context
								.getResources()
								.getAssets()
								.open("new_sports/GAM.png");
						
					}
					
					Bitmap res1 = BitmapFactory.decodeStream(is1);

					Log.i("suraj", "" + res1);

					Bitmap output1 = Bitmap.createBitmap(res1.getWidth(),
							res1.getHeight(), Bitmap.Config.ARGB_8888);
					Canvas canvas1 = new Canvas(output1);

					Paint paint = new Paint();
					Rect rect = new Rect(0, 0, res1.getWidth(),
							res1.getHeight());
					RectF rectF = new RectF(rect);
					float roundPx1 = 8f;

					paint.setAntiAlias(true);
					canvas1.drawARGB(0, 0, 0, 0);
					paint.setColor(0xff424242);
					canvas1.drawRoundRect(rectF, roundPx1, roundPx1, paint);
					paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
					canvas1.drawBitmap(res1, rect, rect, paint);

					holder.image_p1.setImageBitmap(output1);
					holder.image_p1.setScaleType(ScaleType.FIT_CENTER);

					holder.image_p2.setImageBitmap(output1);
					holder.image_p2.setScaleType(ScaleType.FIT_CENTER);
				} else if (player.gettablet() == true) {
					is1 = act_context
							.getResources()
							.getAssets()
							.open("new_sports/"
									+ player.getsport_code() + ".png");

					if(is1==null)
					{
						is1 = act_context
								.getResources()
								.getAssets()
								.open("new_sports/GAM.png");
						
					}
					
					Bitmap res2 = BitmapFactory.decodeStream(is1);

					Log.i("suraj", "" + res2);

					Bitmap output1 = Bitmap.createBitmap(res2.getWidth(),
							res2.getHeight(), Bitmap.Config.ARGB_8888);
					Canvas canvas1 = new Canvas(output1);

					Paint paint = new Paint();
					Rect rect = new Rect(0, 0, res2.getWidth(),
							res2.getHeight());
					RectF rectF = new RectF(rect);
					float roundPx1 = 8f;

					paint.setAntiAlias(true);
					canvas1.drawARGB(0, 0, 0, 0);
					paint.setColor(0xff424242);
					canvas1.drawRoundRect(rectF, roundPx1, roundPx1, paint);
					paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
					canvas1.drawBitmap(res2, rect, rect, paint);

					holder.image_p1.setImageBitmap(output1);
					holder.image_p1.setScaleType(ScaleType.FIT_CENTER);

					holder.image_p2.setImageBitmap(output1);
					holder.image_p2.setScaleType(ScaleType.FIT_CENTER);
				}
			} catch (Exception e) {
			}

		} else {
			holder.tab_row3.setVisibility(View.GONE);

//			LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, 30);
			
//			holder.player1.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, 30));
//			holder.player2.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, 30));
			
			LayoutParams params =  holder.player1.getLayoutParams();
			params.height = 40;
			holder.player1.setLayoutParams(params);
			
			LayoutParams params1 = holder.player2.getLayoutParams();
			params1.height = 40;
			holder.player2.setLayoutParams(params1);
			 
			InputStream is1 = null;
			try {
				if (player.gettablet() == false) {
					is1 = act_context
							.getResources()
							.getAssets()
							.open("new_sports/"
									+ player.getsport_code() + ".png");
					
					if(is1==null)
					{
						is1 = act_context
								.getResources()
								.getAssets()
								.open("new_sports/GAM.png");
						
					}
					Bitmap res1 = BitmapFactory.decodeStream(is1);

					Log.i("suraj", "" + res1);

					Bitmap output1 = Bitmap.createBitmap(res1.getWidth(),
							res1.getHeight(), Bitmap.Config.ARGB_8888);
					Canvas canvas1 = new Canvas(output1);

					Paint paint = new Paint();
					Rect rect = new Rect(0, 0, res1.getWidth(),
							res1.getHeight());
					RectF rectF = new RectF(rect);
					float roundPx1 = 8f;

					paint.setAntiAlias(true);
					canvas1.drawARGB(0, 0, 0, 0);
					paint.setColor(0xff424242);
					canvas1.drawRoundRect(rectF, roundPx1, roundPx1, paint);
					paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
					canvas1.drawBitmap(res1, rect, rect, paint);

					holder.image_p1.setImageBitmap(output1);
					holder.image_p1.setScaleType(ScaleType.FIT_CENTER);

					holder.image_p2.setImageBitmap(output1);
					holder.image_p2.setScaleType(ScaleType.FIT_CENTER);
				} else if (player.gettablet() == true) {
					is1 = act_context
							.getResources()
							.getAssets()
							.open("new_sports/"
									+ player.getsport_code() + ".png");

					if(is1==null)
					{
						is1 = act_context
								.getResources()
								.getAssets()
								.open("new_sports/GAM.png");
						
					}
					Bitmap res2 = BitmapFactory.decodeStream(is1);

					Log.i("suraj", "" + res2);

					Bitmap output1 = Bitmap.createBitmap(res2.getWidth(),
							res2.getHeight(), Bitmap.Config.ARGB_8888);
					Canvas canvas1 = new Canvas(output1);

					Paint paint = new Paint();
					Rect rect = new Rect(0, 0, res2.getWidth(),
							res2.getHeight());
					RectF rectF = new RectF(rect);
					float roundPx1 = 8f;

					paint.setAntiAlias(true);
					canvas1.drawARGB(0, 0, 0, 0);
					paint.setColor(0xff424242);
					canvas1.drawRoundRect(rectF, roundPx1, roundPx1, paint);
					paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
					canvas1.drawBitmap(res2, rect, rect, paint);

					holder.image_p1.setImageBitmap(output1);
					holder.image_p1.setScaleType(ScaleType.FIT_CENTER);

					holder.image_p2.setImageBitmap(output1);
					holder.image_p2.setScaleType(ScaleType.FIT_CENTER);
				}
			} catch (Exception e) {
			}

			if (player.getplayer1() == null
					|| player.getplayer1().equalsIgnoreCase("null")) {
			} else {
				holder.player1.setSelected(true);
				holder.player1.setText(player.getplayer1());
				holder.player1.setGravity(Gravity.CENTER);
				// holder.player1.setTextColor(Color.WHITE);
				holder.player1
						.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
//				holder.player1.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
			}

			if (player.getplayer2() == null
					|| player.getplayer2().equalsIgnoreCase("null")) {
			} else {
				holder.player2.setSelected(true);
				holder.player2.setText(player.getplayer2());
				holder.player2.setGravity(Gravity.CENTER);
				// holder.player1.setTextColor(Color.WHITE);
				holder.player2
						.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
//				holder.player2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
			}

		}

		if (player.getgametext().contains("Double") == true) {
			holder.follow1.setText("FOLLOW");
			holder.follow2.setText("FOLLOW");
		} else {
			Log.d("suraj", "playerAll = " + MainActivity.playerAll);

			Log.d("suraj",
					"follow_btn1.getTag() = "
							+ MainActivity.playerAll.contains(holder.follow1
									.getTag().toString()) + "=="
							+ holder.follow1.getTag().toString());
			Log.d("suraj",
					"follow_btn2.getTag() = "
							+ MainActivity.playerAll.contains(holder.follow2
									.getTag().toString()) + "=="
							+ holder.follow2.getTag().toString());

			if (MainActivity.playerAll != null) {
				if (MainActivity.playerAll.contains(holder.follow1.getTag()
						.toString()) == true) {
					holder.follow1.setText("UNFOLLOW");
				} else {
					holder.follow1.setText("FOLLOW");
				}

				if (MainActivity.playerAll.contains(holder.follow2.getTag()
						.toString()) == true) {
					holder.follow2.setText("UNFOLLOW");
				} else {
					holder.follow2.setText("FOLLOW");
				}
			}
		}

		if (player.getchannel_code1().equals("null")
				|| player.getchannel_code1().equals("NONE")
				|| player.getchannel_code3() == null) {
			holder.channel1.setVisibility(View.INVISIBLE);
		} else {
			holder.channel1.setVisibility(View.VISIBLE);
		}
		//
		if (player.getchannel_code2().equals("null")
				|| player.getchannel_code2().equals("NONE")
				|| player.getchannel_code3() == null) {
			holder.channel2.setVisibility(View.INVISIBLE);
		} else {
			holder.channel2.setVisibility(View.VISIBLE);
		}

		if (player.getchannel_code3().equals("null")
				|| player.getchannel_code3().equals("NONE")
				|| player.getchannel_code3() == null) {
			holder.channel3.setVisibility(View.INVISIBLE);
		} else {
			holder.channel3.setVisibility(View.VISIBLE);
		}

//		Log.d("suraj",
//				"player.getchannel_code1() = " + player.getchannel_code1());
//		Log.d("suraj",
//				"player.getchannel_code2() = " + player.getchannel_code2());
//		Log.d("suraj",
//				"player.getchannel_code3() = " + player.getchannel_code3());
		holder.channel1.setTypeface(sport_font);
		holder.channel2.setTypeface(sport_font);
		holder.channel3.setTypeface(sport_font);
		
		holder.channel1.setText(player.getchannel_code1());
		holder.channel2.setText(player.getchannel_code2());
		holder.channel3.setText(player.getchannel_code3());

		//

		// if (player.gettablet() == false) {
		// p_channel1 = "" + StartActivity.get_img_location
		// + "/ss/images/phone/TV/" + player.getchannel_code1()
		// + ".png";
		// p_channel2 = "" + StartActivity.get_img_location
		// + "/ss/images/phone/TV/" + player.getchannel_code2()
		// + ".png";
		// p_channel3 = "" + StartActivity.get_img_location
		// + "/ss/images/phone/TV/" + player.getchannel_code3()
		// + ".png";
		// new imageTask_channel(holder.channel1).execute(p_channel1);
		//
		// new imageTask_channel(holder.channel2).execute(p_channel2);
		//
		// new imageTask_channel(holder.channel3).execute(p_channel3);
		// } else {
		// p_channel1 = "" + StartActivity.get_img_location
		// + "/ss/images/pad/TV/" + player.getchannel_code1()
		// + "@2x.png";
		// p_channel2 = "" + StartActivity.get_img_location
		// + "/ss/images/pad/TV/" + player.getchannel_code2()
		// + "@2x.png";
		// p_channel3 = "" + StartActivity.get_img_location
		// + "/ss/images/pad/TV/" + player.getchannel_code3()
		// + "@2x.png";
		// new imageTask_channel(holder.channel1).execute(p_channel1);
		//
		// new imageTask_channel(holder.channel2).execute(p_channel2);
		//
		// new imageTask_channel(holder.channel3).execute(p_channel3);
		// }

		return view;
	}

	/*
	 * protected void loginToFacebook() {
	 * 
	 * String access_token = StartActivity.mPrefs.getString("access_token",
	 * null); long expires = StartActivity.mPrefs.getLong("access_expires", 0);
	 * 
	 * if (access_token != null) {
	 * StartActivity.facebook.setAccessToken(access_token);
	 * 
	 * Log.d("FB Sessions", "" + StartActivity.facebook.isSessionValid()); }
	 * 
	 * if (expires != 0) { StartActivity.facebook.setAccessExpires(expires); }
	 * 
	 * if (!StartActivity.facebook.isSessionValid()) {
	 * StartActivity.facebook.authorize(act_context, new String[] { "email",
	 * "publish_stream" }, new DialogListener() {
	 * 
	 * @Override public void onCancel() { }
	 * 
	 * @Override public void onComplete(Bundle values) {
	 * SharedPreferences.Editor editor = StartActivity.mPrefs.edit();
	 * editor.putString("access_token",
	 * StartActivity.facebook.getAccessToken());
	 * editor.putLong("access_expires",
	 * StartActivity.facebook.getAccessExpires()); editor.commit();
	 * 
	 * postToWall(player.getplayer1(),player.getplayer2(),player.getplayer3(),player
	 * .
	 * getplayer4(),player.getChamp_name(),player.getDate(),player.getgametext()
	 * ); }
	 * 
	 * @Override public void onError(DialogError error) {
	 * 
	 * }
	 * 
	 * @Override public void onFacebookError(FacebookError fberror) {
	 * 
	 * }
	 * 
	 * }); } }
	 */

	protected void postToWall(String player1, String player2, String player3,
			String player4, String champ_name, String date, String gametype) {

		String[] date_only = date.split(" ");
		final Bundle postParams = new Bundle();
		if (gametype.contains("Double") == true) {
			postParams.putString("name", player1 + " / " + player3 + " Vs "
					+ player2 + " / " + player4);
			postParams.putString("caption", champ_name);
			postParams.putString("description", date_only[0]);
			postParams
					.putString("link",
							"https://play.google.com/store/apps/details?id=com.sportizz.sport&hl=en");
			postParams.putString("picture",
					"http://sportizza.com/img/phones.png");
		} else {
			postParams.putString("name", player1 + " Vs " + player2);
			postParams.putString("caption", champ_name);
			postParams.putString("description", date_only[0]);
			postParams
					.putString("link",
							"https://play.google.com/store/apps/details?id=com.sportizz.sport&hl=en");
			postParams.putString("picture",
					"http://sportizza.com/img/phones.png");
		}

		act_context.runOnUiThread(new Runnable() {
			@Override
			public void run() {
				WebDialog feedDialog = new WebDialog.FeedDialogBuilder(
						act_context, Session.getActiveSession(), postParams)
						.build();
				feedDialog.show();
			}
		});

	}

	@SuppressWarnings("deprecation")
	@SuppressLint("NewApi")
	public void addToCalendar(Context ctx, final String title,
			final String desc, final long dtstart, final long dtend) {

		Uri eventsUri, reminderuri;

		if (Integer.parseInt(android.os.Build.VERSION.SDK) >= 14) {
			eventsUri = Uri.parse("content://com.android.calendar/events");
			reminderuri = Uri.parse("content://com.android.calendar/reminders");

			ContentValues event = new ContentValues();

			event.put(Events.CALENDAR_ID, 1);
			event.put(Events.TITLE, title);
			event.put(Events.DESCRIPTION, desc);
			event.put(Events.DTSTART, dtstart);
			event.put(Events.DTEND, dtend);
			event.put(Events.STATUS, 1);
			event.put(Events.EVENT_COLOR, Color.RED);

			event.put(Events.HAS_ALARM, 1);
			event.put(CalendarContract.Events.EVENT_TIMEZONE, TimeZone
					.getDefault().getID());

			// To Insert
			Log.v("suraj", "Event =" + TimeZone.getDefault().getID());

			Uri uri = ctx.getContentResolver().insert(
					CalendarContract.Events.CONTENT_URI, event);

			long eventID = Long.parseLong(uri.getLastPathSegment());

			ContentValues reminders = new ContentValues();
			reminders.put(Reminders.EVENT_ID, eventID);
			reminders.put(Reminders.METHOD, Reminders.METHOD_ALERT);
			reminders.put(Reminders.MINUTES, 15);

			ctx.getContentResolver().insert(
					CalendarContract.Reminders.CONTENT_URI, reminders);

			Log.v("suraj", "Reminder =" + reminders);

		} else if (Integer.parseInt(android.os.Build.VERSION.SDK) >= 8
				&& Integer.parseInt(android.os.Build.VERSION.SDK) < 14) {

			eventsUri = Uri.parse("content://com.android.calendar/events");
			reminderuri = Uri.parse("content://com.android.calendar/reminders");
			ContentValues event = new ContentValues();

			event.put(Events.CALENDAR_ID, 1);
			event.put(Events.TITLE, title);
			event.put(Events.DESCRIPTION, desc);
			event.put(Events.DTSTART, dtstart);
			event.put(Events.DTEND, dtend);
			event.put(Events.STATUS, 1);
			event.put(Events.HAS_ALARM, 1);
			event.put(CalendarContract.Events.EVENT_TIMEZONE, TimeZone
					.getDefault().getID());

			Log.v("suraj", "Event =" + TimeZone.getDefault().getID());

			Uri uri = ctx.getContentResolver().insert(eventsUri, event);

			long eventID = Long.parseLong(uri.getLastPathSegment());

			ContentValues reminders = new ContentValues();
			reminders.put(Reminders.EVENT_ID, eventID);
			reminders.put(Reminders.METHOD, Reminders.METHOD_ALERT);
			reminders.put(Reminders.MINUTES, 15);

			ctx.getContentResolver().insert(reminderuri, reminders);

			Log.v("suraj", "Reminder =" + reminders);
		}
	}

	@Override
	public int getViewType() {
		return Rowtype.PLAYER_ROW.ordinal();
	}

	private static class ViewHolder {

		final TextView day;
		final TextView date;
		final TextView sport_name;
		final TextView champ_name;
		final TextView game_txt;
		final TextView match_txt;
		final ImageView image_p1;
		final ImageView image_p2;

		final TextView player1;
		final TextView player2;

		final TextView player3;
		final TextView player4;

		final TableRow tab_row3;

		final TextView channel1;
		final TextView channel2;
		final TextView channel3;
		final Button follow1;
		final Button follow2;
		final Button btn_player_cal;
		final LinearLayout linearLayout;
		final Button ticket;

		public ViewHolder(LinearLayout linearLayout, TextView day, TextView date, TextView sport_name,
				TextView champ_name, TextView game_txt, TextView match_txt, ImageView image_p1, ImageView image_p2,
				TextView player1, TextView player2, TextView player3,
				TextView player4, TableRow tabRow, TextView channel1,
				TextView channel2, TextView channel3, Button p_follow1,
				Button p_follow2, Button add_cal,Button ticket) {

			this.day = day;
			this.date = date;
			this.sport_name = sport_name;
			this.champ_name = champ_name;
			this.game_txt= game_txt; 
			this.match_txt =match_txt;
			this.ticket = ticket;
			
			this.image_p1 = image_p1;
			this.image_p2 = image_p2;
			this.player1 = player1;
			this.player2 = player2;

			this.player3 = player3;
			this.player4 = player4;

			this.tab_row3 = tabRow;

			this.channel1 = channel1;
			this.channel2 = channel2;
			this.channel3 = channel3;
			this.follow1 = p_follow1;
			this.follow2 = p_follow2;
			this.btn_player_cal = add_cal;
			this.linearLayout =linearLayout;
		}
	}
/*
	private class imageTask extends AsyncTask<String, Void, Bitmap> {
		ImageView imageView = null;

		imageTask(ImageView iv) {
			this.imageView = iv;
		}

		@Override
		protected Bitmap doInBackground(String... params) {
			try {
				return download_Image(params[0]);

			} catch (OutOfMemoryError e) {
				return null;
			}
		}

		@Override
		protected void onPostExecute(Bitmap result) {
			if (player.getgametext().contains("Double") == true) {
				InputStream is = null;
				try {
					if (player.gettablet() == false) {
						is = act_context
								.getResources()
								.getAssets()
								.open("default_images/phone/"
										+ player.getsport_code() + ".png");
					} else if (player.gettablet() == true) {
						is = act_context
								.getResources()
								.getAssets()
								.open("default_images/phone/"
										+ player.getsport_code() + "@2x.png");
					}
					result = BitmapFactory.decodeStream(is);
				} catch (Exception e) {
					result = BitmapFactory.decodeResource(
							act_context.getResources(), R.drawable.ic_launcher);
				}

				Bitmap output = null;
				Canvas canvas;
				float roundPx;

				output = Bitmap.createBitmap(result.getWidth(),
						result.getHeight(), Bitmap.Config.ARGB_8888);
				canvas = new Canvas(output);

				Paint paint = new Paint();
				Rect rect = new Rect(0, 0, result.getWidth(),
						result.getHeight());
				RectF rectF = new RectF(rect);
				roundPx = 8f;

				paint.setAntiAlias(true);
				canvas.drawARGB(0, 0, 0, 0);
				paint.setColor(0xff424242);
				canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
				paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
				canvas.drawBitmap(result, rect, rect, paint);

				imageView.setImageBitmap(output);
				imageView.setScaleType(ScaleType.FIT_CENTER);

			} else

			{
				Bitmap output = null;
				Canvas canvas;
				float roundPx;
				if (result == null) {

					InputStream is = null;
					try {
						if (player.gettablet() == false) {
							is = act_context
									.getResources()
									.getAssets()
									.open("default_images/phone/"
											+ player.getsport_code() + ".png");
						} else if (player.gettablet() == true) {
							is = act_context
									.getResources()
									.getAssets()
									.open("default_images/phone/"
											+ player.getsport_code()
											+ "@2x.png");
						}
						result = BitmapFactory.decodeStream(is);
					} catch (Exception e) {
						result = BitmapFactory.decodeResource(
								act_context.getResources(),
								R.drawable.ic_launcher);
					}

					output = Bitmap.createBitmap(result.getWidth(),
							result.getHeight(), Bitmap.Config.ARGB_8888);
					canvas = new Canvas(output);

					Paint paint = new Paint();
					Rect rect = new Rect(0, 0, result.getWidth(),
							result.getHeight());
					RectF rectF = new RectF(rect);
					roundPx = 8f;

					paint.setAntiAlias(true);
					canvas.drawARGB(0, 0, 0, 0);
					paint.setColor(0xff424242);
					canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
					paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
					canvas.drawBitmap(result, rect, rect, paint);

					imageView.setImageBitmap(output);
					imageView.setScaleType(ScaleType.FIT_CENTER);

				} else {

					output = Bitmap.createBitmap(result.getWidth(),
							result.getHeight(), Bitmap.Config.ARGB_8888);
					canvas = new Canvas(output);

					Paint paint = new Paint();
					Rect rect = new Rect(0, 0, result.getWidth(),
							result.getHeight());
					RectF rectF = new RectF(rect);
					roundPx = 8f;

					paint.setAntiAlias(true);
					canvas.drawARGB(0, 0, 0, 0);
					paint.setColor(0xff424242);
					canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
					paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
					canvas.drawBitmap(result, rect, rect, paint);

					imageView.setImageBitmap(output);
					imageView.setScaleType(ScaleType.FIT_CENTER);
				}
			}
			super.onPostExecute(result);
		}

		private Bitmap download_Image(String url) {
			// ---------------------------------------------------
			Bitmap bm = null;
			try {
				URL aURL = new URL(url);
				URLConnection conn = aURL.openConnection();
				conn.connect();
				InputStream is = conn.getInputStream();
				BufferedInputStream bis = new BufferedInputStream(is);
				bm = BitmapFactory.decodeStream(bis);
				bis.close();
				is.close();
			} catch (Exception e) {
				Log.e("Hub", "Error getting the image from server : ");

				InputStream iss = null;
				try {
					iss = act_context
							.getResources()
							.getAssets()
							.open("default_images/phone/"
									+ player.getsport_code() + ".png");
				} catch (IOException e1) {
					e1.printStackTrace();
				}
				return BitmapFactory.decodeStream(iss);

			}
			return bm;

		}

	}
*/	
	
	public int getImgLoader(String sport_code) {

		int loader = R.drawable.gam;
		
		if(sport_code.equalsIgnoreCase("AFT"))
		{
			loader = R.drawable.aft;
		}else if(sport_code.equalsIgnoreCase("TT"))
		{
			loader = R.drawable.tt;
		}else if(sport_code.equalsIgnoreCase("POL"))
		{
			loader = R.drawable.pol;
		}else if(sport_code.equalsIgnoreCase("SWI"))
		{
			loader = R.drawable.swi;
		}else if(sport_code.equalsIgnoreCase("UFC"))
		{
			loader = R.drawable.ufc;
		}else if(sport_code.equalsIgnoreCase("BAD"))
		{
			loader = R.drawable.bad;
		}else if(sport_code.equalsIgnoreCase("BB"))
		{
			loader = R.drawable.bb;
		}else if(sport_code.equalsIgnoreCase("CRI"))
		{
			loader = R.drawable.cri;
		}else if(sport_code.equalsIgnoreCase("F1"))
		{
			loader = R.drawable.f1;
		}else if(sport_code.equalsIgnoreCase("GAM"))
		{
			loader = R.drawable.gam;
		}else if(sport_code.equalsIgnoreCase("GOL"))
		{
			loader = R.drawable.gol;
		}else if(sport_code.equalsIgnoreCase("HOC"))
		{
			loader = R.drawable.hoc;
		}else if(sport_code.equalsIgnoreCase("ICE"))
		{
			loader = R.drawable.ice;
		}else if(sport_code.equalsIgnoreCase("IND"))
		{
			loader = R.drawable.ind;
		}else if(sport_code.equalsIgnoreCase("MGP"))
		{
			loader = R.drawable.mgp;
		}else if(sport_code.equalsIgnoreCase("NAS"))
		{
			loader = R.drawable.nas;
		}else if(sport_code.equalsIgnoreCase("OLY"))
		{
			loader = R.drawable.oly;
		}else if(sport_code.equalsIgnoreCase("RUG"))
		{
			loader = R.drawable.rug;
		}else if(sport_code.equalsIgnoreCase("SBK"))
		{
			loader = R.drawable.sbk;
		}else if(sport_code.equalsIgnoreCase("SOC"))
		{
			loader = R.drawable.soc;
		}else if(sport_code.equalsIgnoreCase("SPO"))
		{
			loader = R.drawable.spo;
		}else if(sport_code.equalsIgnoreCase("SQU"))
		{
			loader = R.drawable.squ;
		}else if(sport_code.equalsIgnoreCase("TEN"))
		{
			loader = R.drawable.ten;
		}else if(sport_code.equalsIgnoreCase("V8C"))
		{
			loader = R.drawable.v8c;
		}else if(sport_code.equalsIgnoreCase("WRC"))
		{
			loader = R.drawable.wrc;
		}
		else
		{
			loader = R.drawable.gam;
		}
		return loader;
	}

}
